package main

import "fmt"

type I interface {
}

func main() {
	assertString("aaa")
	assertString(124)

	fmt.Println("\n------")
	a := "string"
	b := 100
	c := true
	var i I
	assertJudge(a)
	assertJudge(b)
	assertJudge(c)
	assertJudge(i)
}

func assertString(i interface{}) {
	s, ok := i.(string)
	if ok {
		fmt.Println(s)
	} else {
		fmt.Println(i, "不是string类型")
	}

}

func assertJudge(i interface{}) {
	switch i.(type) {
	case string:
		fmt.Println(i, "string类型")
	case int:
		fmt.Println(i, "int类型")
	case I:
		fmt.Println(i, "I类型")
	case nil:
		fmt.Println(i, "nil类型")
	default:
		fmt.Println(i, "未知类型")
	}
}
